Chens


  • 首页

  • 标签

  • 分类

  • 归档

Best Time to Buy and Sell Stock 2

发表于 2019-03-14 | 分类于 贪心 , leetcode

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public:
int maxProfit(vector<int>& prices) {
int n=prices.size();
int sum=0;//定义利润
for(int i=1;i<n;i++)
{
if(prices[i]-prices[i-1]>0)
sum+=prices[i]-prices[i-1];
}
return sum;
}
};
安装cuda8+cudnn5.1+tensorflowgpu+keras
Best Time to Buy and Sell Stock
Chens

Chens

201 日志
59 分类
2 标签
© 2019 Chens
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.4